import { Component, ChangeDetectionStrategy, ViewChild } from '@angular/core';

import { TableHeader } from "../interface-shared";

@Component({
  selector: 'table-simple',
  changeDetection: ChangeDetectionStrategy.OnPush,
  templateUrl: 'table-simple.component.html',
  styleUrls: ['table-simple.component.less'],
  inputs: ['data', 'header']
})

export class TableSimpleComponent {
  profile: any = null;
  constructor () {}

  showProfile (e, h, profile, profileEl) {
    if (!h.mouseover) return
    this.profile = profile
    profileEl.style.top = e.layerY ? e.layerY + 10 + 'px' : '0px';
    profileEl.style.left = e.layerX ? e.layerX + 10 + 'px' : '400px';
  }

  hideProfile (h, profileEl) {
    if (!h.mouseover) return
    this.profile = null
    profileEl.style.top = '-10000px'
    profileEl.style.left = '-10000px'
  }

  trackByHeader (index: number, header: TableHeader) {
    return header.key
  }

  trackByItem (index: number, item: any) {
    return index
  }
}
